﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ninject;
using Ninject.Modules;
using Site.Infrastructure.Logging;
using Ninject.Activation;
using WikiGame.Models;
using WikiGame.Utilities;
using System.Web.Mvc;
using WikiGame.Infrastructure.ErrorHandling;
using WikiGame.Infrastructure.Membership;

namespace WikiGame.Infrastructure.Ninject
{
    public class AppModule : NinjectModule
    {

        public override void Load()
        {
            Bind<ILogger>().To<NLogLogger>().WithConstructorArgument("currentClassName", r => getCurrentClassName(r));
            Bind<ICategoryProvider>().To<TestCategoryProvider>().InSingletonScope();
            Bind<IExceptionFilter>().To<ElmahErrorHandler>();
            Bind<IAccountRepository>().To<DummyAccountRepository>();
        }

        private object getCurrentClassName(IContext r)
        {
            if (r.Request.ParentContext == null)
                return "WikiGameApp";
            else 
                return 	r.Request.ParentContext.Request.Service.FullName;
        }
    }
}